/*
This code was generated with the qrsc utility (QRemoteSignal interface
compiler) version R0.0 from file:
qrs.xml

Do not modify this file directly. Modify interface description and
run qrsc once again.
*/
#include "tvclient.h"

#include <QRemoteSignal>

using namespace qrs;

const QString TvClient::mName = "Tv";

TvClient::TvClient ( ServicesManager* parent ): AbsService(parent) {
   parent->registerService(this);
}

void TvClient::startSlideshow() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("startSlideshow");
   msg.setService(mName);

   manager()->send(msg);
}

void TvClient::setSlideDelay(const int& delay) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setSlideDelay");
   msg.setService(mName);
   msg.params().insert("delay",qrs::createArg(delay));

   manager()->send(msg);
}

void TvClient::setSlideAnim(const QString& type) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setSlideAnim");
   msg.setService(mName);
   msg.params().insert("type",qrs::createArg(type));

   manager()->send(msg);
}

void TvClient::stopSlideshow() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("stopSlideshow");
   msg.setService(mName);

   manager()->send(msg);
}

void TvClient::startRunningLine() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("startRunningLine");
   msg.setService(mName);

   manager()->send(msg);
}

void TvClient::setRunningText(const QString& text) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setRunningText");
   msg.setService(mName);
   msg.params().insert("text",qrs::createArg(text));

   manager()->send(msg);
}

void TvClient::setRunningSpeed(const int& speed) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setRunningSpeed");
   msg.setService(mName);
   msg.params().insert("speed",qrs::createArg(speed));

   manager()->send(msg);
}

void TvClient::setRunningColor(const QString& color) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setRunningColor");
   msg.setService(mName);
   msg.params().insert("color",qrs::createArg(color));

   manager()->send(msg);
}

void TvClient::stopRunningLine() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("stopRunningLine");
   msg.setService(mName);

   manager()->send(msg);
}

void TvClient::startMessage() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("startMessage");
   msg.setService(mName);

   manager()->send(msg);
}

void TvClient::stopMessage() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("stopMessage");
   msg.setService(mName);

   manager()->send(msg);
}

void TvClient::setMessageType(const QString& type) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setMessageType");
   msg.setService(mName);
   msg.params().insert("type",qrs::createArg(type));

   manager()->send(msg);
}

void TvClient::setMessageText(const QString& text) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setMessageText");
   msg.setService(mName);
   msg.params().insert("text",qrs::createArg(text));

   manager()->send(msg);
}

void TvClient::setMessageColor(const QString& color) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setMessageColor");
   msg.setService(mName);
   msg.params().insert("color",qrs::createArg(color));

   manager()->send(msg);
}

void TvClient::startVideos() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("startVideos");
   msg.setService(mName);

   manager()->send(msg);
}

void TvClient::stopVideos() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("stopVideos");
   msg.setService(mName);

   manager()->send(msg);
}

void TvClient::setTimeSchedule(const int& service, const QString& schedule) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("setTimeSchedule");
   msg.setService(mName);
   msg.params().insert("service",qrs::createArg(service));
   msg.params().insert("schedule",qrs::createArg(schedule));

   manager()->send(msg);
}

void TvClient::sendState() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("sendState");
   msg.setService(mName);

   manager()->send(msg);
}


void TvClient::processMessage (const Message& msg)
      throw(IncorrectMethodException) {
   if ( msg.service() != mName ) {
      throw( IncorrectMethodException(AbsService::tr("Invalid service name: %1").arg(msg.service())) );
}

   if ( msg.method() == "slideshowStarted" ) {
      emit slideshowStarted(  );
      return;
}
   if ( msg.method() == "slideshowStopped" ) {
      emit slideshowStopped(  );
      return;
}
   if ( msg.method() == "slideDelayChanged" ) {
      int delay;
      if ( ! msg.params().contains("delay") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("delay").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["delay"], delay) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("delay") ) );
}
      emit slideDelayChanged( delay );
      return;
}
   if ( msg.method() == "slideAnimChanged" ) {
      QString type;
      if ( ! msg.params().contains("type") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("type").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["type"], type) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("type") ) );
}
      emit slideAnimChanged( type );
      return;
}
   if ( msg.method() == "runningLineStarted" ) {
      emit runningLineStarted(  );
      return;
}
   if ( msg.method() == "runningLineStopped" ) {
      emit runningLineStopped(  );
      return;
}
   if ( msg.method() == "runningLineTextChanged" ) {
      QString text;
      if ( ! msg.params().contains("text") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("text").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["text"], text) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("text") ) );
}
      emit runningLineTextChanged( text );
      return;
}
   if ( msg.method() == "runningLineColorChanged" ) {
      QString color;
      if ( ! msg.params().contains("color") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("color").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["color"], color) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("color") ) );
}
      emit runningLineColorChanged( color );
      return;
}
   if ( msg.method() == "runningLineSpeedChanged" ) {
      int speed;
      if ( ! msg.params().contains("speed") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("speed").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["speed"], speed) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("speed") ) );
}
      emit runningLineSpeedChanged( speed );
      return;
}
   if ( msg.method() == "messageStarted" ) {
      emit messageStarted(  );
      return;
}
   if ( msg.method() == "messageStopped" ) {
      emit messageStopped(  );
      return;
}
   if ( msg.method() == "messageTextChanged" ) {
      QString text;
      if ( ! msg.params().contains("text") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("text").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["text"], text) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("text") ) );
}
      emit messageTextChanged( text );
      return;
}
   if ( msg.method() == "messageTypeChanged" ) {
      QString type;
      if ( ! msg.params().contains("type") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("type").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["type"], type) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("type") ) );
}
      emit messageTypeChanged( type );
      return;
}
   if ( msg.method() == "messageColorChanged" ) {
      QString color;
      if ( ! msg.params().contains("color") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("color").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["color"], color) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("color") ) );
}
      emit messageColorChanged( color );
      return;
}
   if ( msg.method() == "videosStarted" ) {
      emit videosStarted(  );
      return;
}
   if ( msg.method() == "videosStopped" ) {
      emit videosStopped(  );
      return;
}
   if ( msg.method() == "timeScheduleChanged" ) {
      int service;
      if ( ! msg.params().contains("service") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("service").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["service"], service) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("service") ) );
}
      QString schedule;
      if ( ! msg.params().contains("schedule") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("schedule").arg(msg.method()) ) );
}
      if ( !qrs::getArgValue(msg.params()["schedule"], schedule) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("schedule") ) );
}
      emit timeScheduleChanged( service, schedule );
      return;
}

   throw( IncorrectMethodException( AbsService::tr("Unknown method %1").arg(msg.method()) ) );
}
